﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using hospital_registration_system.DAL;
using hospital_registration_system.Entity;

namespace hospital_registration_system.BLL
{
    /// <summary>
    /// 医生表服务
    /// </summary>
    public class DoctorService
    {
        DoctorDao dao = null;
        public DoctorService()
        {
            dao = new DoctorDao();
        }
        /// <summary>
        /// 查找所有的医生
        /// </summary>
        /// <returns>返回所有科室的链表</returns>
        public List<Doctor> selectAllDoctors()
        {
            return dao.selectAll();
        }
        /// <summary>
        /// 删除指定id的医生
        /// </summary>
        /// <param name="id">要删除的医生的id</param>
        /// <returns>是否删除成功</returns>
        public bool deleteDoctorById(int id)
        {
            if (id < 0) return false;//检查id属性是否符合要求
            return dao.delete(id);
        }

        /// <summary>
        /// 修改医生信息
        /// </summary>
        /// <param name="doctor">被修改的医生信息</param>
        /// <returns>是否修改成功</returns>
        public bool updateDoctor(Doctor doctor)
        {
            if (doctor == null || doctor.Id < 0)
            {
                return false;
            }
            return dao.update(doctor);
        }

        /// <summary>
        /// 插入一条只有姓名的医生信息
        /// </summary>
        /// <param name="name">要插入的医生姓名</param>
        /// <returns>是否执行成功</returns>
        public bool insertDoctor(String name)
        {
            Doctor doctor = new Doctor();
            doctor.Doctor_name = name;
            return dao.insert(doctor);
        }
    }
}
